Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create drawAuras hook #15450

Closed
wants to merge 5 commits into from
Closed

Create drawAuras hook #15450

wants to merge 5 commits into from

Conversation

MrVauxs
Copy link
Contributor

@MrVauxs MrVauxs commented Jul 15, 2024

Creates 3 informational hooks, deletedAuras, createdAuras, and updatedAuras. Hopefully self-explanatory.
The arguments they give are the AuraRenderers object itself, and then an array of slugs of the auras that were somehow changed.

Primarily for use with the WIP PF2e Graphics module, such as animating size-changing auras. Ex. Issue MrVauxs/pf2e-jb2a-macros#157

@stwlam
Copy link
Collaborator

stwlam commented Jul 15, 2024

augury for this says "woe"

@MrVauxs
Copy link
Contributor Author

MrVauxs commented Jul 15, 2024

Elaborate?

@CarlosFdez
Copy link
Collaborator

CarlosFdez commented Oct 15, 2024

I might be amenable if there's no other recourse to a drawAuras hook that passes in the previous slugs as an argument, but doing the computation ourselves in what is already performance sensitive code just in case a module uses it isn't something I could really agree with.

@MrVauxs
Copy link
Contributor Author

MrVauxs commented Oct 15, 2024

I might be amenable if there's no other recourse to a drawAuras hook that passes in the previous slugs as an argument, but doing the computation ourselves in what is already performance sensitive code just in case a module uses it isn't something I could really agree with.

So using this PR as an example, it would be a hook that provides the preUpdateSlugs and the token that's called after this.draw()?

So something akin to

 async reset(slugs?: string[]): Promise<void> {
        const preUpdateSlugs = Array.from(this.keys());
        
        ...
        
        return this.draw().then(() => Hooks.callAll("drawAuras", this.token, preUpdateSlugs));
}

@CarlosFdez
Copy link
Collaborator

I would await instead of using then, but yes, though perhaps in an object, so Hooks.callAll("drawAuras", this.token, { preUpdateSlugs }).

I don't mind if its before or after, whichever follows the pattern of most draw/render hooks.

@MrVauxs
Copy link
Contributor Author

MrVauxs commented Oct 15, 2024

I would use await as well if it was possible to have code run after returning it lol
And I don't know if anything relies on reset() returning that promise.

As for running it before, it sounds somewhat counter to the name of drawAuras

@CarlosFdez
Copy link
Collaborator

CarlosFdez commented Oct 15, 2024

its a Promise<void>. The only reason we return is because returning a promise is the same as awaiting.

@MrVauxs
Copy link
Contributor Author

MrVauxs commented Oct 15, 2024

The only reason we return is because returning a promise is the same as awaiting.

TIL

Making the changes.

@CarlosFdez CarlosFdez changed the title Create hooks for auras Create drawAuras hook Oct 16, 2024
@CarlosFdez
Copy link
Collaborator

CarlosFdez commented Oct 16, 2024

As awkward as it may be to work around, remove the preUpdateSlugs. It has more of a chance going through without it. I'll do research on existing hooks to see if we need to change the name as well.

Placeables have the following hooks
-----------
createX(placeableDocument, options, id) - when placed or created
drawX(placeable, options) - draw function called
refreshX(placeable, options) - ticker updates, usually for animations
hoverX(placeable, options) - when hovering over it
drawX(placeable) - when added or dragged (but only once)
preDeleteX(placeableDocument, options, id)
destroyX(placeable)
deleteX(placeableDocument, options, id)

Documents also have
----------
preUpdateX(actor, updates, flags)
updateX(actor, updates, flags, id)
renderX(app, domElement, getDataResults)

Miscellaneous canvas hooks
------------
initializePointLightSourceShaders(PointLightSource)
lightingRefresh(EffectsCanvasGroup)
sightRefresh(CanvasVisbility)
canvasPan(Canvas, coords)

@MrVauxs
Copy link
Contributor Author

MrVauxs commented Nov 7, 2024

As a note, I have removed the preUpdateSlugs. The changeset is now just adding a Hooks.callAll("drawAuras", this.token); at the end.

@CarlosFdez
Copy link
Collaborator

I've reconnected after, and without the diffing of before/after or some way to even store what it was before, this PR has no use. It would be better served by a post prepared hook, which would be able to handle this situation. I'd recommend asking core foundry for such a hook though.

@CarlosFdez CarlosFdez closed this Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants